using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Utility;
using ENTITIES;
using BUS;


public partial class admin_DangNhap : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Url.ToString().Contains("DangNhap.aspx") == false
       && Session["UserName"] == null)
            Response.Redirect("~/admin/DanhSachDoanhNghiep.aspx");
    }
    protected void btn_DangNhap_Click(object sender, EventArgs e)
    {
        Criteria cri = new Criteria();
        cri.add(Condition.AND, tbNhanVienColumns.TaiKhoan.ToString(), Condition.EQUAL,
        txt_TaiKhoan.Text);
        int total = 0;
        tbNhanVienCollection nhanvienCollection = NhanVienBUS.Get(
        cri.Criter, 0, 0, tbNhanVienColumns.MaNV.ToString(), OrderDirection.ASC.ToString(), out total);
        if (nhanvienCollection.Count > 0)
        {
            if (nhanvienCollection[0].matkhau== txt_MatKhau.Text)
            {
                Session["UserName"] = txt_TaiKhoan.Text;
                Response.Redirect("~/admin/DanhSachDoanhNghiep.aspx");
            }
            else
            {
                lb_Error.Text = "Mat khau sai. Vui long dang nhap lai";
            }

        }
        else
        {
            lb_Error.Text = "Tai khoan khong ton tai. Vui long dang nhap lai";
        }
    }
}

